package model

import "github.com/doujunyu/gogo/sql_aid"

const TableByUserShoppingCart = "self_user_shopping_cart"

// UserShoppingCartByCount 当前购物车商品数量
func UserShoppingCartByCount(userId int64)int64{
	userShoppingCartSql, args := sql_aid.PgTable(TableByUserShoppingCart).Field("count(id) as count_id").Where("user_id = ?", userId).ToSql()
	userShoppingCartData, err := sql_aid.DataToMap(PgSql.Query(userShoppingCartSql, args...))
	if err != nil {
		return 0
	}
	return userShoppingCartData[0]["count_id"].(int64)
}


